<!--
 * @Date: 2020-08-07 11:30:21
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2020-09-22 16:16:39
 * @Description: 二级按钮 管理自身状态
-->

<template>
  <div class="bmp-second-menu-content"  >
    <div
      class="icon-content"
      :class="currSelected?'icon-selected':'icon-unselected'"
      @click="togSelect"
    ></div>
    <div class="text-content" >
      <baseOverFlowText :text="text"></baseOverFlowText>
    </div>
  </div>
</template>
<script>
import baseOverFlowText from '@/components/Base/baseOverFlowText.vue'
export default {
  data () {
    return {
      currSelected: false
    }
  },
  inject: ['secondMenuStatusChange', 'firstTag'],
  components: {
    baseOverFlowText
  },
  model: {
    prop: 'selected',
    event: 'change'
  },
  watch: {
    currSelected: {
      handler (nv) {
        this.$emit('change', nv)
        this.secondMenuStatusChange(nv, this.tag, this.firstTag)
      },
      immediate: true
    },
    selected: {
      handler (nv) {
        this.currSelected = nv
      },
      immediate: true
    }
  },
  props: {
    tag: {
      type: String,
      default: ''
    },
    selected: {
      type: Boolean,
      default: false
    },
    text: {
      type: String,
      default: ''
    }
  },
  methods: {
    togSelect (type) {
      if (typeof type === 'boolean') {
        this.currSelected = type
      } else {
        this.currSelected = !this.currSelected
      }
    }
    // clickItem(){

    // }
  }
}
</script>
<style lang="scss" scoped>
.bmp-second-menu-content {
  height: 26px;
  width: 100%;
  padding-bottom: 9px;
  .icon-content {
    float: left;
    margin-left: 19px;
    height: 14px;
    width: 14px;
    cursor: pointer;
  }
  .icon-selected {
    background-image: url('~@/assets/menuicon/select2.png');
  }
  .icon-unselected {
    background-image: url('~@/assets/menuicon/unselect2.png');
  }
  .text-content {
    float: left;
    margin-left: 9px;
    width: calc(100% - 42px);
    font-size: 12px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: rgba(255, 255, 255, 1);
    line-height: 17px;
    ::v-deep .baseOverFlowContent {
      margin-left: 10%;
      width: 90%;
    }
    ::v-deep .baseOverFlow {
      display: block !important;
      text-align: left !important;
    }
  }
}
</style>
